import SuperRouter from './superRouter.js';

export default class hashRouter extends SuperRouter{
    constructor(routerlist) {
        super(routerlist);
        this.render(this.getPath());
        window.addEventListener('hashchange', () => {
            this.render(this.getPath());
        }, false)
    }
    getPath() {
        return location.hash ?  location.hash.substr(1) : '';
    }
    
    push(path) {
        location.hash = path;
    }
    replace(path) {
        location.hash = path;
         window.location.replace(`${location.origin}/#${path}`);
    }
}